package top.shaozuo.simple.rest.client;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;

public class RestClientDemo {

	public static void main(String[] args) {
		Client client = ClientBuilder.newClient();
		Response response = client.target("http://127.0.0.1:8080/myapp/myresource") // WebTarget
		        .request() // Invocation.Builder
		        .post(Entity.json(new User("id", "shaozuo"))); // jnn Response

		String content = response.readEntity(String.class);

		System.out.println(content);
	}

}

class User {
	String id;
	String name;

	public User() {
	}

	public User(String id, String name) {
		super();
		this.id = id;
		this.name = name;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}
